<?php
namespace App\Model\BbcModel;

use Service\Code\Normal;
use App\Model\BaseModel\BaseBbcModel;

/**
 * 大小B 微信相关配置
 */
class ChannelWx extends BaseBbcModel {

    public $table = 'ly_channel_wx';

    /**
     * 相关公众号配置参数
     */
    public static function getWx(array $param = []) {
        if (!isset($param['cid']) || empty($param['cid'])) {
            return Normal::returnCode(Normal::FAIL, 'expect param cid');
        }
        $config = ConfigChannel::where('cid', $param['cid'])->where('code', 'wxmp_pay')->value('value');
        if (empty($config)) {
            return Normal::returnCode(Normal::FAIL, '没有相关公众号配置参数');
        }
        $value = json_decode($config, true);
        $data  = [
            'code'  => 'wxmp_pay',
            'value' => [
                'app_id'    => $value['appid'],
                'appsecret' => $value['appsecret'],
                'mch_id'    => $value['mch_id'],
                'key'       => $value['key'],
                'cert'      => $value['cert'],
                'cid'       => $param['cid'],
            ],
        ];
        return Normal::returnCode(Normal::SUC, '请求成功', $data);
    }

}